package com.qst.controller;

import com.qst.domain.VipUser;
import com.qst.dto.Result;
import com.qst.dto.UserDTO;
import com.qst.service.IVipUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.sql.ResultSet;

@RestController
@RequestMapping("/user")
public class VipUserController {

    @Resource
    private IVipUserService vipUserService;

    @PostMapping("/addUser")
    public Result addUser(@RequestBody VipUser vipUser) {
        return vipUserService.saveVipUser(vipUser);
    }

    @DeleteMapping("/delete/{id}")
    public Result deleteUser(@PathVariable("id") Long id){
        return vipUserService.deleteVipUserById(id);
    }

    @PutMapping("/update")
    public Result updateUser(@RequestBody VipUser vipUser){
        return vipUserService.updateVipUser(vipUser);
    }

    @PostMapping("/update/userDto")
    public Result updateUser(@RequestBody UserDTO userDTO){
        return vipUserService.updateUserById(userDTO);
    }

    @GetMapping("/{id}")
    public VipUser queryUser(@PathVariable("id") Long id){
        return vipUserService.getById(id);
    }

    @GetMapping("/ledger/{id}")
    public Result queryLedgers(@PathVariable("id") Long id) {
        return vipUserService.findVipUserLedgerById(id);
    }

    @GetMapping("/points/{id}")
    public Result queryPoints(@PathVariable("id") Long id) {
        return vipUserService.findVipUserPointById(id);
    }
}
